﻿<!DOCTYPE html>
<html>
<head>
    <title>JS Strings Exercise 1</title>
    <link href="styles/js-console.css" rel="stylesheet" />
</head>
<body>
    <h1>Function reverses string and returns it.</h1>
    <label for="str-input">String:</label>
    <input type="text" id="str-input" />
    <button onclick="execute()">execute</button>
    <div id="js-console"></div>
    <script src="scripts/js-console.js"></script>
    <script>
        function reverseStr(str)
        {
            var retStr = "";
            var strLen = str.length;
            for (var idx = strLen - 1; idx >= 0; idx--)
            {
                retStr += str[idx];
            }

            return retStr;
        }

        function execute()
        {
            var inpStr = jsConsole.read("#str-input");

            jsConsole.writeLine(reverseStr(inpStr));
        }
    </script>
</body>
</html>
